<template>
    <a-row :gutter="16" class="mt-4 mb-5 text-right">
        <a-col :span="4">
            <div style="font-weight: bold;">系统信息</div>
        </a-col>
    </a-row>
    <a-row :gutter="16">
        <a-col :span="12">
            <a-form-item label="申请人" name="createUserName">
                <a-input v-model:value="form.createUserName" disabled style="width: 100%" placeholder="" />
            </a-form-item>
        </a-col>
        <a-col :span="12">
            <a-form-item label="申请时间" name="createTime">
                <a-input v-model:value="form.createTime" disabled style="width: 100%" placeholder="" />
            </a-form-item>
        </a-col>
    </a-row>
    <a-row :gutter="16">
        <a-col :span="12">
            <a-form-item label="申请部门" name="orgName">
                <a-input v-model:value="form.orgName" disabled style="width: 100%" placeholder="" />
            </a-form-item>
        </a-col>
    </a-row>
</template>
<script setup>
import dayjs from 'dayjs'
import tool from '@/utils/tool'
const userInfo = tool.data.get('USER_INFO')
const form = ref({})
const props = defineProps({
    value: {
        type: Object,
    }
})
watch(
    () => props.value,
    (newVal, oldVal) => {
        const now = dayjs();
        console.log("watch system")
        if(newVal.createTime){
        // if (Object.keys(newVal).length != 0) {
            form.value = { ...newVal }
            if (form.value.createTime) {
                const formattedNow = dayjs(form.value.createTime).format('YYYY-MM-DD HH:mm');
                form.value.createTime = formattedNow
            }
            if(!form.value.createUserName&&form.value.initiatorName){
                form.value.createUserName=newVal.initiatorName
            }
        } else {
            form.value.createUserName = userInfo.name
            const formattedNow = now.format('YYYY-MM-DD HH:mm');
            form.value.orgName = userInfo.orgName
            form.value.createTime = formattedNow
        }
    },
    { deep: true, immediate: true }
)

</script>